package cn.edu.neusoft.yuejian12.Fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import java.util.List;

import cn.edu.neusoft.yuejian12.Activity.ClubInfoActivity;
import cn.edu.neusoft.yuejian12.Adapter.ClubAdapter;
import cn.edu.neusoft.yuejian12.Adapter.HmasterAdapter;
import cn.edu.neusoft.yuejian12.Adapter.TrainListAdapter;
import cn.edu.neusoft.yuejian12.JavaBean.Club;
import cn.edu.neusoft.yuejian12.JavaBean.Master;
import cn.edu.neusoft.yuejian12.JavaBean.TrainInfo;
import cn.edu.neusoft.yuejian12.Model.ClubModel;
import cn.edu.neusoft.yuejian12.Model.MasterModel;
import cn.edu.neusoft.yuejian12.Model.TrainModel;
import cn.edu.neusoft.yuejian12.R;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by 木子李 on 2017/9/27.
 */

public class ClubFragment  extends Fragment {
    private RecyclerView recyclerView;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        View view = inflater.inflate(R.layout.tab03,container,false);
        recyclerView = (RecyclerView) view.findViewById(R.id.rv_club);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));//设置布局
        showData();
        return view;
    }
    private void showData(){
        ClubModel clubModel = new ClubModel();
        Call<List<Club>> call = clubModel.getAllclub();
        call.enqueue(new Callback<List<Club>>() {
            @Override
            public void onResponse(Call<List<Club>> call, Response<List<Club>> response) {
                List<Club> mDataList = response.body();
                recyclerView.setAdapter(new ClubAdapter(ClubFragment.this.getContext(),mDataList));//设置适配器，绑定Adapter.
            }

            @Override
            public void onFailure(Call<List<Club>> call, Throwable t) {

            }
        });
    }

}
